#ifndef PM_DB_OBJECT_H_INCLUDED
#define PM_DB_OBJECT_H_INCLUDED

#include <wx/string.h>
#include <wx/wxsqlite3.h>
#include <list>

namespace db
{

typedef int ID;

typedef std::pair<bool, wxSQLite3Statement> update_value_type;

class Object
{
    ID m_id;

public:
    enum { undefined = -1 };

protected:
    Object();
    Object(wxSQLite3ResultSet& res);
	virtual ~Object();

public:
    ID id() const { return m_id; }
    bool valid() const { return m_id != undefined; }
	
	bool insert(wxSQLite3Database& db);
	
	bool update(wxSQLite3Database& db);
	
protected:
	int last_insert_id(wxSQLite3Database& db);

	virtual update_value_type prepare_insert(wxSQLite3Database& db) = 0;
	virtual update_value_type prepare_update(wxSQLite3Database& db) = 0;
};

} // namespace db

#endif // PM_DB_OBJECT_H_INCLUDED
